﻿using UnityEngine;
using System.Collections;

public class EnemyCreater : MonoBehaviour 
{
	

	public GameObject[]enemyPrefabs;
	public float creatInterval = 2f;//间隔时间

	void Start()
	{
		
		InvokeRepeating ("CreatOne",0,creatInterval);
	}

	void CreatOne()
	{
		int index = Random.Range (0, enemyPrefabs.Length);
		GameObject prefab = enemyPrefabs [index];
		Vector2 pos = new Vector2 (Random.Range(-2.5f,2.5f),6);
		Instantiate (prefab,pos,Quaternion.identity);
	}



}
